home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / test / overlay.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1999-01-07  |  2.5 KB  |  85 lines

  1. //
  2. // "$Id: overlay.cxx,v 1.4 1999/01/07 19:17:59 mike Exp $"
  3. //
  4. // Overlay window test program for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. #include <stdlib.h>
  27. #include <stdio.h>
  28. #include <FL/Fl.H>
  29. #include <FL/Fl_Window.H>
  30. #include <FL/Fl_Overlay_Window.H>
  31. #include <FL/Fl_Button.H>
  32. #include <FL/fl_draw.H>
  33.  
  34. int width=10,height=10;
  35.  
  36. class overlay : public Fl_Overlay_Window {
  37. public:
  38.   overlay(int w,int h) : Fl_Overlay_Window(w,h) {}
  39.   void draw_overlay();
  40. };
  41.  
  42. void overlay::draw_overlay() {
  43.   fl_color(FL_RED); fl_rect((w()-width)/2,(h()-height)/2,width,height);
  44. }
  45.  
  46. overlay *ovl;
  47.  
  48. void bcb1(Fl_Widget *,void *) {width+=20; ovl->redraw_overlay();}
  49. void bcb2(Fl_Widget *,void *) {width-=20; ovl->redraw_overlay();}
  50. void bcb3(Fl_Widget *,void *) {height+=20; ovl->redraw_overlay();}
  51. void bcb4(Fl_Widget *,void *) {height-=20; ovl->redraw_overlay();}
  52.  
  53. int arg(int, char **argv, int& i) {
  54.   Fl_Color n = (Fl_Color)atoi(argv[i]);
  55.   if (n<=0) return 0;
  56.   i++;
  57.   uchar r,g,b;
  58.   Fl::get_color(n,r,g,b);
  59.   Fl::set_color(FL_RED,r,g,b);
  60.   return i;
  61. }
  62.  
  63. int main(int argc, char **argv) {
  64.   int i=0; Fl::args(argc,argv,i,arg);
  65.   ovl = new overlay(400,400);
  66.   Fl_Button *b;
  67.   b = new Fl_Button(50,50,100,100,"wider\n(a)");
  68.   b->callback(bcb1); b->shortcut('a');
  69.   b = new Fl_Button(250,50,100,100,"narrower\n(b)");
  70.   b->callback(bcb2); b->shortcut('b');
  71.   b = new Fl_Button(50,250,100,100,"taller\n(c)");
  72.   b->callback(bcb3); b->shortcut('c');
  73.   b = new Fl_Button(250,250,100,100,"shorter\n(d)");
  74.   b->callback(bcb4); b->shortcut('d');
  75.   ovl->resizable(ovl);
  76.   ovl->end();
  77.   ovl->show(argc,argv);
  78.   ovl->redraw_overlay();
  79.   return Fl::run();
  80. }
  81.  
  82. //
  83. // End of "$Id: overlay.cxx,v 1.4 1999/01/07 19:17:59 mike Exp $".
  84. //
  85.